<?php 

	require "config.php";

?>
<!DOCTYPE html>
<html lang="hu">
	<head>
		<!-- TITLE -->
		<title>Scholafy</title>
		
		<!-- METAS -->
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		
		<!-- STYLE -->
		<link rel="stylesheet" href="css/style.css">
		
		<!-- GOOGLE FONTS -->
		<link rel="preconnect" href="https://fonts.googleapis.com">
		<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
		<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100&family=Nunito+Sans:opsz@6..12&display=swap" rel="stylesheet">
		
		<!-- FONT AWESOME -->
		<script src="https://kit.fontawesome.com/086e7cefb3.js" crossorigin="anonymous"></script>
		
		<!-- REFRESHER -->
		<!-- <meta http-equiv="refresh" content="2"> -->
	</head>
	<body>
		<div class="side-menu">
			 <div class="menu">
				<ul>
					<li><a href="#"><i class="fa-solid fa-house"></i></a></li>
					<li><a href="kereses.php"><i class="fa-solid fa-magnifying-glass"></i></a></li>
				</ul>
			 </div>
			 <div class="playlists">
				<ul>
					<li><a href="#"><i class="fa-solid fa-book"></i></a></li>
					<li><a href="favs.php" title="Kedvencek"><i class="fa-solid fa-heart"></i></a></li>
					<li><a href="#" onclick="newPlaylist()" title="Új lista létrehozása"><i class="fa-solid fa-plus"></i></a></li>
				</ul>
			 </div>
		</div>
		<div class="content-box">
			<div class="content-header">
				<h1>Kedvenceid</h1>
				<div class="musics">
					<?php 
						// $lekerdezes = "SELECT artists.username, music.name, music.file_name FROM favs WHERE userid=$_COOKIE[id]";
						$lekerdezes = "SELECT artists.username, music.name, music.file_name
							FROM favs
							INNER JOIN music on favs.musicid=music.id
							INNER JOIN artists ON music.artistid=artists.id
							WHERE favs.userid=$_COOKIE[id]
							ORDER BY favs.id DESC";
						$talalt_k = $conn->query($lekerdezes);
						while($kedvenc=$talalt_k->fetch_assoc()){
					?>
						<div class="music">
							<p><?= $kedvenc['username']; ?> - <?= $kedvenc['name']; ?></p>
							<audio controls>
								<source src="files/<?= $kedvenc['file_name']; ?>" type="audio/mp3">
							</audio>
						</div>
					<?php } ?>
				</div>
			</div>
		</div>
		
	</body>
</html>